package com.csd.service.impl;

import com.csd.po.SysUser;
import com.csd.mapper.UserMapper;
import com.csd.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: CeSuDi_SSM
 * @author: qinjianbao
 * @create: 2020-12-22 16:27
 * @Version: 1.0
 */
@Service
public class UserServiceImpl implements UserService {
    //注入CarUserMapper
    @Autowired(required = false)
    private UserMapper userMapper;

    /**
     * 用户登录功能
     * @param tel 用户名
     * @param password 用户密码
     * @return 返回用户实体
     */
    @Override
    public SysUser findByNameAndPwd(String tel, String password) {
        SysUser carUserMapper = userMapper.findByName(tel);
        //判断密码是否相等
        if (password.equals(carUserMapper.getPassword())){
            return carUserMapper;
        }else {
            return null;
        }
    }

    @Override
    public SysUser findByTel(String tel) {
        SysUser sysusertel = userMapper.findByName(tel);

        return sysusertel;

    }

    @Override
    public void insertUser(SysUser sysUser) {

       userMapper.addUser(sysUser);

    }

    @Override
    public void updateUser(SysUser sysUser) {
        userMapper.updateUser(sysUser);
    }
}
